import axios from "axios";

const BASEURL = "http://xue.cnkdl.cn:8809";

export default function (url, data = {}, method = "GET", headers = {}) {
  return new Promise((resolve, reject) => {
    axios({
      url: BASEURL + url,
      data:data,
      method: method,
      headers: headers,
      // params: method === "GET" ? data : "",
      // data: ["POST", "PUT","GET"].includes(method) ? data : "",
      // responseType: "json",
    })
      .then((res) => {
        resolve(res);
      })
      .catch((err) => {
        reject(err);
      });
  });
}
